<?php
defined('_JEXEC') or die('Restricted access');
JToolBarHelper::title(JText::_('NS Pro HTML Templates'), 'thememanager.png');

$jversion = new JVersion();
$j15 = ($jversion->RELEASE == '1.5');

jimport('joomla.application.component.helper');
$params = JComponentHelper::getParams( 'com_nspro' );
if ($j15 == true) {
  $component = JComponentHelper::getComponent( 'com_nspro' );
  $params = new JParameter( $component->params );
}

$db =& JFactory::getDBO();

?>

<form action="index.php" method="post" name="adminForm">
<div id="editcell">
    <table class="adminlist">
    <thead>
        <tr>
            <th width="5">
                <?php echo JText::_( 'ID' ); ?>
            </th>
            <th width="20">
                <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->templates ); ?>);" />
            </th>
            <th class="title">
                <?php echo JText::_('Name'); ?>
            </th>
            <th width="140">
                <?php echo JText::_( 'Thumbnail' ); ?>
            </th>
            <th width="50%">
              <?php print JText::_('HTML Code'); ?>
            </th>
            <th width="20%" class="notes">
                <?php echo JText::_( 'Notes' ); ?>
            </th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <td colspan="8">
                <?php
                  print $this->pagination->getListFooter();
                ?>
            </td>
        </tr>
    </tfoot>
    <tbody>
    <?php
    $k = 0;
    for ($i=0, $n=count( $this->templates ); $i < $n; $i++)
    {
        $row = &$this->templates[$i];
        $row->checked_out = false;
        $checked    = JHTML::_('grid.checkedout', $row, $i );
        $link       = JRoute::_( 'index.php?option=com_nspro&controller=nspro&task=tedit&cid[]='. $row->id );

        ?>
        <tr class="<?php echo "row$k"; ?>">
            <td>
                <?php echo $row->id; ?>
            </td>
            <td>
                <?php echo $checked; ?>
            </td>
            <td align="center">
                <a href="<?php echo $link; ?>"><?php echo $row->tname; ?></a>
            </td>
            <td align="center">
              <?php
                if ($row->thumbpath != '') {
                  print '<img src="' . $row->thumbpath . '" width="135" style="border: 1px solid #000;"/>';
                }
                else {
                  print JText::_('N/A');
                }
              ?>
            </td>
            <td>
              <?php
                if (strlen(htmlentities($row->tcode)) > 500) {
                  print JString::substr(htmlentities($row->tcode), 0, 500) . '...';
                }
                else {
                  print htmlentities($row->tcode);
                }
              ?>
            </td>
            <td>
                <?php echo $row->notes; ?>
            </td>
        </tr>
        <?php
        $k = 1 - $k;
    }
    ?>
    </tbody>
    </table>

<input type="hidden" name="option" value="com_nspro" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="controller" value="nspro" />
</form>
<br/>
<center><small><i>NS Pro by <a href="http://www.mavrosxristoforos.com/">Mavrosxristoforos.com</a> Copyright 2009-2011</i></small></center>
</div>
